package cn.com.pc.content.dto;

import cn.com.pc.content.domain.Biz;
import cn.com.pc.content.domain.Site;
import cn.com.pc.content.domain.tag.TagTree;
import lombok.Data;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Data
@ToString
public class TagTreeDTO {
    private Long id;
    //    private TagTree parent;
    @NotNull(message = "parentId不能为空")
    private Long parentId;
    private Site site;
    private Biz biz;
    @NotBlank(message = "name不能为空")
    private String name;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    public static TagTreeDTO from(TagTree tagTree) {
        TagTreeDTO tagTreeDTO = new TagTreeDTO();
        BeanUtils.copyProperties(tagTree, tagTreeDTO);
        return tagTreeDTO;
    }
}
